// ---------- 通用返回结构 ----------
export interface Result {
  code: string;
  msg: string;
}

export interface ResultData<T = any> extends Result {
  data: T;
}

// ---------- 分页 ----------
export interface ResPage<T> {
  list: T[];
  pageNum: number;
  pageSize: number;
  total: number;
}

export interface ReqPage {
  pageNum: number;
  pageSize: number;
}

// ---------- 上传模块 ----------
export namespace Upload {
  export interface ResFileUrl {
    fileUrl: string;
  }
}

// ---------- 登录模块 ----------
export namespace Login {
  export interface ReqLoginForm {
    username: string;
    password: string;
  }

  export interface ResLogin {
    access_token: string;
    username: string;
    userId: string;
    permissions: string;
  }

  export interface ResAuthButtons {
    [key: string]: string[];
  }
}

// ---------- 客户管理模块 ----------
export namespace Customer {
  export interface ContactPerson {
    id?: string;
    name: string;
    position: string;
    phone: string;
    trainingExperience?: string;
    remarks?: string;
  }

  export interface CustomerInfo {
    id: string;
    enterpriseName: string;
    address: string;
    logo?: string;
    mainBusiness: string;
    applicationScenario: string;
    annualOutputValue?: number;
    employeeCount?: number;
    upstreamSuppliers?: string;
    downstreamCustomers?: string;
    trainingExperience?: string;
    otherInfo?: string;
    resourceInfo?: string;
    confusedQuestions?: string;
    contacts: ContactPerson[];
    createTime?: string;
    updateTime?: string;
    status?: number;
  }

  export interface DynamicCustomerInfo extends CustomerInfo {
    [key: string]: any;
  }

  export interface ReqCustomerParams extends ReqPage {
    enterpriseName?: string;
    mainBusiness?: string;
    status?: number;
    startTime?: string;
    endTime?: string;
  }

  export interface UpdatedPassword {
    userId: string;
    oldPassword: string;
    newPassword: string;
  }

  export interface ResStatus {
    label: string;
    value: number;
  }
}

// ---------- 表单配置结构 ----------
export interface FormConfig {
  key: string;
  label: string;
  require: boolean;
  inputType?: string;
  unit?: string;
  placeholderTemplate?: string;
}

export interface ColumnForm<T = any> {
  prop: string;
  label: string;
  isShow: boolean;
  renderType: string;
  formConfig: FormConfig[];
  required: boolean;
  category: string;
  placeholderTemplate?: string;
  unit?: string;
}

export interface RuleConfig {
  required?: boolean;
  pattern?: RegExp;
  message?: string;
  trigger?: string;
}

export interface FieldConfig {
  prop: string;
  label: string;
  isShow: boolean;
  renderType: string;
  required?: boolean;
  category: string;
  formConfig?: any[];
  placeholderTemplate?: string;
  unit?: string;
  displayField?: string | string[];
}
